﻿@model QLMB.ViewModels.InfoFlight

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
@section script {
    <script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
    <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
}
<script language = "javascript" type ="text/javascript">
    $(document).ready(function () {
        $("#Sanbaydi").change(function () {
            var idSbdi = $(this).val();
            $.getJSON("/Book/GetListArriveAirport/", { id: idSbdi },
                function (json) {
                    var select = $("#Sanbayden");
                    select.empty();
                    select.attr("data-val", true);
                    select.attr("data-val-required", "Vui long chon san bay den");
                    select.attr("class", "input-validation-error");
                    select.append($('<option/>', {
                        value: 0,
                        text: "Chon diem den"
                    }));
                    $.each(json, function (index, itemData) {
                        select.append($('<option/>', {
                            value: itemData.Value,
                            text: itemData.Text
                        }));
                    });
                });
        });
        $("#Sanbayden").change(function () {
            if ($(this).val() != 0)
                $(this).attr("class", "valid");
            else
                $(this).attr("class", "input-validation-error");
        });

        $("input[name=Loaive]").change(function () {
            if ($(this).val() == "Mot chieu")
                $("#timetoback").hide();
            else
                $("#timetoback").show();
        });

        $("#SoNguoiLon").change(function () {
            var ste = 6 - $(this).val();
            var select = $("#SoTreEm");
            select.empty();
            if (ste < 3) {
                for (i = 0; i <= ste; i++) {
                    select.append($('<option/>', {
                        value: i,
                        text: i
                    }));
                }
            }
            else {
                for (i = 0; i < 3; i++) {
                    select.append($('<option/>', {
                        value: i,
                        text: i
                    }));
                }
            }
        });
        $('.date').datepicker({ dateFormat: "mm/dd/yy", maxDate: '+1y', minDate: '+1d' });
    });

</script>

<h2>ĐẶT VÉ CHUYẾN BAY - Chọn thời gian, địa điểm</h2>
@using (Html.BeginForm())
{
    <center>
<table>
    <tr>
        <td align = "right">@Html.RadioButtonFor(x => x.Loaive, "Mot chieu", true)Mot chieu</td>
        <td align = "left">@Html.RadioButtonFor(x => x.Loaive, "Khu hoi", false)Khu hoi</td>
    </tr>
    <tr>
        <td align = "right">@Html.LabelFor(x => x.Sanbaydi):</td>
        <td align = "left">@Html.DropDownListFor(x => x.Sanbaydi, new SelectList(Model.Sbdi, "Value", "Text"), "Chon diem di")</td>
    </tr>
    <tr>
        <td align = "right">@Html.LabelFor(x => x.Sanbayden):</td>
        <td align = "left">@Html.DropDownListFor(x => x.Sanbayden, new SelectList(Model.Sbden, "Value", "Text"), "Chon diem den")</td>
    <tr>
        <td align ="right">Thời gian đi</td>
        <td align ="left">@Html.EditorFor(x => x.Ngaydi)</td>
    </tr>
    <tr id = "timetoback">
        <td align ="right">Thời gian về</td>
        <td align ="left">@Html.EditorFor(x => x.Ngayve)</td>
    </tr>    
    <tr>
        <td align ="right">@Html.LabelFor(x => x.SoNguoiLon):</td>
        <td align = "left">@Html.DropDownListFor(x => x.SoNguoiLon, new SelectList(new[]
                                    {
                                        new{val = 1, Text = "1"},
                                        new{val = 2, Text = "2"},
                                        new{val = 3, Text = "3"},
                                        new{val = 4, Text = "4"},
                                        new{val = 5, Text = "5"},
                                        new{val = 6, Text = "6"},
                                    }, "val", "text"))</td>
    </tr>
    <tr>
        <td align = "right">@Html.LabelFor(x => x.SoTreEm)</td>
        <td align = "left">@Html.DropDownListFor(x => x.SoTreEm, new SelectList(new[]
                                    {
                                        new{val = 0, Text = "0"},
                                        new{val = 1, Text = "1"},
                                        new{val = 2, Text = "2"},
                                    }, "val", "text"))</td>
    </tr>
</table>
<input type="submit" value="Tim kiem" />
</center>
}